package com.hs.springframwork;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * bean工厂
 *
 * @Author lingNan
 * @Date 2022/1/7 5:12 下午
 **/
public class BeanFactory {

    private final Map<String,BeanDefinition> beanMap = new ConcurrentHashMap<String, BeanDefinition>();

    public void registeredBean(String beanName,Object obj){
        if(beanMap.containsKey(beanName)){
           return;
        }
        BeanDefinition definition = new BeanDefinition();
        definition.setObj(obj);
        beanMap.put(beanName,definition);
    }

    public Object getBean(String beanName){
        return beanMap.get(beanName).getObj();
    }
}
